package com.neo.impatient.C08_extends.C08_07_anonymousChildClass




class Person(str: String){
  println(str)
}

class AnonyTest {


  //匿名子类,可以通过包含带有定义或者重写代码的方式创建一个匿名子类
  val alien  = new Person("Fred"){
    def greeting = "Grettings, Earthling ! My name is Fred"
  }


  private[this] def meet(p: Person{def greeting: String}){
    println(s"aaaaaaaaaaaaaaaaa \n${p.getClass},\n${p.greeting}")
  }

  def Test(): Unit ={
    meet(alien)
  }
}

object AnonyTest{

  def main(args: Array[String]): Unit = {
    val aa = new AnonyTest()

    aa.Test()
  }
}
